package CutLoad.components.window
{
	/**
	 * 带有滚动条多行文本窗口 
	 * @author smallerbird mail:smallerbird@gmail.com  site:www.mkigm.com QQ群:49983196
	 * 
	 */
	import CutLoad.Base;
	import CutLoad.components.CTextArea;
	
	import flash.display.Sprite;
	public class CWindowTextArea extends Base
	{
		private var window:CWindow;
		private var txt:CTextArea;
		private var funClose:Function=null;
		public function init(strTitle:String="",isCloseBtn:Boolean=true,isDrag:Boolean=true,isShowMinMaxBtn:Boolean=false,w:Number=400,h:Number=300):CWindowTextArea{
			window=new CWindow();
			window.init(strTitle,isCloseBtn,isDrag,isShowMinMaxBtn,w,h,this);
			window.show(this);
			txt=new CTextArea();
			txt.init(window.getContainerShowWidth(),window.getContainerShowHeight())
			window.getContainer().append(txt,true);
			//txt.setWH(window.getContainerShowWidth(),window.getContainerShowHeight());
			return this;
		}
		override public function getShowWidth():Number{
			return window.getShowWidth();
		}
		override public function getShowHeight():Number{
			return window.getShowHeight();
		}
		/**
		 * 改变大小 
		 * @param w
		 * @param h
		 * 
		 */		
		override public function setWH(w:Number=0, h:Number=0):void{
			window.setWH(w,h);
			txt.setWH(window.getContainerShowWidth(),window.getContainerShowHeight());
		}
		/**
		 * 设置关闭按钮是作的额外方法,注：设置方法时，如果close按钮没有显示，会自动打开
		 * @param fun 格式:function(自身:CWindowTextArea);
		 * 
		 */			
		public function setFunClose(fun:Function):void{
			funClose=fun
			window.setFunCloseBtn(funCloseWin);
		}
		private function funCloseWin(me:CWindow):void{
			//这里类的父类不是CWindow,而是base里放入一个CWindow,所以传出的方法，应该是base
			var meTem:CWindowTextArea=me.parent as CWindowTextArea;
			funClose(meTem);
		}
		/**
		 * 获里边的window部件 
		 * @return 
		 * 
		 */		
		public function getPartWindow():CWindow{
			return window;
		}
		/**
		 * 返回 窗口内部的：带有滚动条多行文本
		 * @return 
		 * 
		 */		
		public function getTextArea():CTextArea{
			return txt;
		}
		/**
		 * 设置文本内容 
		 * @param str
		 * 
		 */		
		public function set text(str:String):void{
			txt.text=str
		}
		/**
		 * 获得文本内容 
		 * @return 
		 * 
		 */		
		public function get text():String{
			return txt.text;
		}
		/**
		 * 设置文本内容 
		 * @param str
		 * 
		 */		
		public function appendText(str:String):void{
			txt.appendText(str);
		}
		/**
		 * 设置文本html内容 
		 * @param str
		 * 
		 */		
		public function set htmlText(str:String):void{
			txt.htmlText=str
		}
		/**
		 * 追加 文本html内容 
		 * @param str
		 * 
		 */		
		public function appendHtmlText(str:String):void{
			txt.appendHtmlText(str);
		}
	}
}